﻿/**
* @author alex
*/
Namespace("sketch.framework");

(function () {
    var fwk = sketch.framework;
    fwk.DrawBuffer = function(){
        var canvas = document.createElement("canvas");
        var width = 0, height = 0;
        this.context = canvas.getContext("2d");

        this.width = function(/*int*/value){
            if(arguments.length === 1 && value != width){
                width = canvas.width = value;
            }

            return width;
        }
        this.height = function(/*int*/value){
            if(arguments.length === 1 && value != height){
                height = canvas.height = value;
            }

            if(height < 0)
            {
                height = 0;
            }

            return height;
        }
        this.draw = function(context, left, top){
            context.drawImage(canvas, left, top);
        }
        this.clear = function(){
            this.context.clearRect(0, 0, this.width(), this.height());
        }
    }
})();